package com.doyens.controller;

import com.doyens.common.R;
import com.doyens.entity.Student;
import com.doyens.service.ExamService;
import com.doyens.utils.ValidateCodeUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@Slf4j
@RestController
@RequestMapping("/student")
@Api(tags ="学生考试登陆接口")
public class LoginController {

    @Autowired
    private ExamService examService;

    @ApiModelProperty(value = "登录")
    @PostMapping("/login")
    public R<String> sendMsg(@RequestBody Student student, HttpSession session) {
        //获取手机号
        String phone = student.getPhone();
        if (StringUtils.isNotEmpty(phone)) {
            //生成随机的四位数验证码
            String code = ValidateCodeUtils.generateValidateCode(4).toString();
            log.info("code={}",code);
        }
        return R.error("短信发送失败");
    }



}
